<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>



    <p  id="timeout" name="timeout" hidden data-timeout="${TIME_OUT}" ></p>
    <div class="dgg-list-top-warp">
        <div class="screen-search" >
            <ul>
                <li>
                    <label>客户姓名：</label>
                    <input type="text" class="dggui-input dggui-input-normal" id="customerName" name="customerName" placeholder="输入客户姓名" maxlength="50">
                </li>
                <li>
                    <label>所属生产事业部：</label>
                    <select id="productOrgId" id="productOrgId" name="productOrgId" >
                    </select>
                </li>
                <%--<li>
                    <label>订单状态：</label>
                    <select name="orderStatus" id="orderStatus" class="dggui-select" >
                        <option value=''>请选择</option>
                        <option value="RZSCORDER_STATUS11" <c:if test="${code == 'RZSCORDER_STATUS11'}">selected = selected</c:if>>转单待接收</option>
                        <option value="RZSCORDER_STATUS01" <c:if test="${code == 'RZSCORDER_STATUS01'}">selected = selected</c:if>>下单待接收</option>
                        <option value="RZSCORDER_STATUS16" <c:if test="${code == 'RZSCORDER_STATUS16'}">selected = selected</c:if>>退回待接收</option>
                    </select>
                </li>--%>
                <li>
                    <label>业务类型：</label>
                    <div name="typeCode" id="typeCode"></div>
                </li>
                <%--<li>
                    <label>产品：</label>
                    <select name="productCode" id="productCode" >
                    </select>
                </li>
                <li>
                    <label>渠道：</label>
                    <select name="channelCode" id="channelCode" class="dggui-select">
                        <option value=''>请选择</option>
                    </select>
                </li>--%>
                <li>
                    <label>流程人员：</label>
                    <select id="flowUserId" name="flowUserId"  >
                    </select>
                </li>
                <li>
                    <label>签单商务：</label>
                    <select  id="signUserId" name="signUserId">
                    </select>
                </li>
                <li>
                    <label>签单部门：</label>
                    <div class="tree-select-warp">
                        <input type="text" class="dggui-input input-selct-tree" id="signOrg" name="signOrg" data-id="" value="" style="width: 320px" />
                    </div>
                </li>
              <%--  <li>
                    <label>签单时间：</label>
                    <input type="text" readonly class="dggui-input dggui-time-range" id="signTime" name="signTime">
                    <i class="iconfont icon-rili"></i>
                </li>--%>
               <%-- <li>
                    <label>分配时间：</label>
                    <input type="text" readonly class="dggui-input dggui-time-range" id="allotDate" name="allotDate">
                    <i class="iconfont icon-rili"></i>
                </li>--%>
                <li>
                    <label>关键字：</label>
                    <input type="text" class="dggui-input dggui-input-large" id="searchKey" name="searchKey" placeholder="订单编号/生产单编号/客户号码" maxlength="50" style="width: 190px;">
                </li>
               <%-- <li>
                    <label>需求金额：</label>
                    <input type="number" class="dggui-input dggui-input-large" id="moneyMin" name="moneyMin" placeholder="输入最小金额" min="0">~
                    <input type="number" class="dggui-input dggui-input-large" id="moneyMax" name="moneyMax" placeholder="输入最大金额" min="0">
                </li>--%>
                <li>
                    <button class="dggui-btn searchBtn">搜索</button>
                    <button class="dggui-btn dggui-btn-primary" onclick="cleanSearch()">清空条件</button>
                    <d:hasUrlAuth authCode="RZSC_OPERATION_EXPORT">
                    <button class="dggui-btn dggui-btn-green" onclick="excelExportWaitReceive()">导出</button>
                    </d:hasUrlAuth>
                </li>
            </ul>
        </div>
    </div>
    <div class="list-content">
        <div class="tool-bar">
            <div class="fl"  id="waitAcdept">
                <d:hasUrlAuth authCode="RZSC_OPERATION_CALL">
                <a href="javascript:void(0)"class="dggui-btn" onclick="callPhoneByProduction($('#waitOrder'))">打电话</a>
                </d:hasUrlAuth>
                <d:hasUrlAuth authCode="RZSC_OPERATION_RECEIVE">
                <a href="javascript:void(0)"class="dggui-btn" onclick="receive()">接收</a>
                </d:hasUrlAuth>

                <d:hasUrlAuth authCode="RZSC_OPERATION_WASTE_BILL">
                <a href="javascript:void(0)"class="dggui-btn" onclick="nullify($('#waitOrder'))">废单</a>
                </d:hasUrlAuth>
                <d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_ORDER">
                <a href="javascript:void(0)"class="dggui-btn" onclick="transfer()">转单</a>
                </d:hasUrlAuth>
                <d:hasUrlAuth authCode="RZSC_OPERATION_CHANGE_BACK">
                <a href="javascript:void(0)"class="dggui-btn" onclick="blackOrderPage($('#waitOrder'))">转单退回</a>
                </d:hasUrlAuth>
            </div>
            <div class="fr node-state" >
                <ul>
                    <li class="over-finish">订单超期</li>
                    <li>节点超期</li>
                    <li class="over">接收超期</li>
                </ul>
            </div>
        </div>
        <div class="table-warp">
            <table class="dggui-table" id="waitOrder">
        </table>
        </div>
    </div>


<script>
    /**
     * 订单接收
     */
    function receive(){
        var trs = getChecked("#waitOrder");
        if (trs.length == 0) {
            dggui.dialog.errors('请选择一条数据');
            return;
        }
        var id = trs[0].id;
        var ids  = new Array();
        trs.forEach(function (e) {
            ids.push(e.id.toString());
        });
        var orderIds= JSON.stringify(ids);
        if (trs.length > 1) {
            receiveBatch(orderIds,'waitOrder');
        }else{
            dggui.dialog.loading();
            $.ajax({
                type: 'POST',
                url: sysInfo.basePath + "/rzsc/processing_order/verify_old.do",
                data:{
                    id:id
                },
                success: function (res) {
                    dggui.dialog.loading('close');
                    //老数据单个接收绕过单个接收走批量接收
                    if (res.code == 0&&res.data==0) {
                        receiveBatch(orderIds,'waitOrder');
                    }else if (res.code==0&&res.data==1) {
                        receiveSingle(id,$("#waitOrder"));
                    }else {
                        dggui.dialog.errors("流程数据错误");
                    }
                }
            });

        }
    }



    /**
     * 转单
     */
    function transfer(){
        var checkDate = $('#waitOrder').dataTableExtend('getCheck');
        if(checkDate.length < 1){
            dggui.dialog.errors('请至少选择一条数据！');
            return;
        }
        var ids = [];
        for(var i=0;i<checkDate.length;i++){
            ids.push(checkDate[i].id);
        }
        ids = ids.join(",");
        transferOrder(ids,$('#waitOrder'));
    }
</script>
<script>
    /**
     * 废单
     */
 /*   function nullify() {
        var data = getChecked($('#waitOrder'));
        if ("" == data || data.length==0) {
            dggui.dialog.errors("请至少选择一条要退回的数据！", 3000);
            return;
        }else if (data.length > 10) {
            dggui.dialog.errors("最多选择10条数据！", 3000);
        } else {
            var ids = new Array();
            data.forEach(function (e) {
                ids.push(e.id.toString());
            });
            console.log(JSON.stringify(ids));
            nullifyPage(ids, $("#inProcess"));
        }
    }*/

</script>
